﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TryTools
{
    /// <summary>
    /// 类型转换器
    /// </summary>
    public static class Converter
    {
        public static byte TryToByte(string num)
        {
            byte.TryParse(num, out byte result);
            return result;
        }

        public static int TryToInt(string num)
        {
            int.TryParse(num, out int result);
            return result;
        }

        public static long TryToLong(string num)
        {
            long.TryParse(num, out long result);
            return result;
        }

        public static float TryToFloat(string num)
        {
            float.TryParse(num, out float result);
            return result;
        }

        public static double TryToDouble(string num)
        {
            double.TryParse(num, out double result);
            return result;
        }

        public static decimal TryToDecimal(string num)
        {
            decimal.TryParse(num, out decimal result);
            return result;
        }
    }
}
